let arr = [1,2,3,4,5]



Array.prototype.myreduce = function(callback, ...value) {
    let start = 0
    if(value.length) {
        value = value[0]
    }
    else {
        value = this[0]
        start = 1
    }
    for(let i = start; i < this.length; i++) {
        value = callback(value, this[i], i)
    }
    return value
}

console.log(arr.myreduce((pre, next, i) => {
    return pre + next
}));